module.exports = function(grunt){

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        //=====js合并=====
        concat: {
            biketo_book: {
                files: {
                    "./js/script.js": ["./js/libs/*.js", "./js/module/*.js"],
                    "./less/style_book.less": [
                        "./less/libs/reset.less",
                        "./less/libs/public.less",
                        "./less/libs/module/*.less",
                        "./less/module/home/*.less"
                    ],
                    "./less/style_detail.less": [
                        "./less/libs/reset.less",
                        "./less/libs/public.less",
                        "./less/libs/module/*.less",
                        "./less/module/book_detail/libs/*.less",
                        "./less/module/book_detail/style_bible.less",
                        "./less/module/book_detail/style_travel.less"
                    ]
                }
            }
        },
        //=====js压缩=====
        uglify: {
            biketo_book: {
                files: {
                    "./js/script.min.js": "./js/script.js"
                }
            }
        },
        //=====less编译=====
        less: {
            biketo_book: {
                files: {
                    "./css/style_book.css": "./less/style_book.less",
                    "./css/style_detail.css": "./less/style_detail.less"
                }
           }
        },
        //=====css压缩=====
        cssmin: {
            biketo_book: {
                files: [{
                    expand: true,
                    cwd: './css/',
                    src: ['*.css', '!*.min.css'],
                    dest: './dest/css/',
                    ext: '.min.css'
                }]
            }
        },
        //=====外部css与js文件替换成压缩版=====
        htmlrefs: {
            biketo_book: {
                files: [{
                    expand: true,
                    cwd: './',
                    src: ['*.html'],
                    dest: 'dest/'
                }]
            }
        },
        //=====文件复制=====
        copy: {
            template: {
                 src: ['./css/style_book.min.css', './js/script.min.js', './img/**/*'], dest: './dest/'
            }
        },

        watch: {
            concat: {
                files: [
                    './less/libs/*.less',
                    './less/module/**/*.less',
                    './js/module/*.js'
                ],
                tasks: 'concat'
            },
            less: {
                files: './less/style_book.less',
                tasks: ['less']
            }
         }
    });

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-htmlrefs');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['concat', 'less', 'cssmin', 'uglify', 'htmlrefs', 'copy', 'watch']);
	

};